-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[Parser] Eliminate 'CommentRetentionMode::None' in Lexer #85927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@swift-ci Please smoke test |
|
@swift-ci Please smoke test macOS |
|
@swift-ci Please smoke test Linux |
Lexer should always set `Token.CommentLength` correctly because it necessary for restoring to the token position with comments. Otherwise, 'Token::isAtStartOfLine()' might not correctly set.
unittests/Parse/LexerTests.cpp
Outdated
| Lexer L(LangOpts, SourceMgr, BufferID, /*Diags=*/nullptr, LexerMode::Swift, | ||
| HashbangMode::Disallowed, CommentRetentionMode::None); | ||
| HashbangMode::Disallowed, CommentRetentionMode::AttachToNextToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was specifically testing CommentRetentionMode::None behavior. Removing the case.
(CommentRetentionMode::AttachToNextToken behavior is tested in BOMAttachCommentNoTrivia)
53fdf19 to
dffd88e
Compare
|
@swift-ci Please smoke test |
|
@swift-ci Please smoke test Linux |
|
@swift-ci Please smoke test Windows |
Fixes: #85922
Lexer should always set
Token.CommentLengthcorrectly because it's necessary for restoring the token position with comments. Otherwise,Token::isAtStartOfLine()might not correctly set. (see:Lexer::getStateForBeginningOfToken())